#ifndef ITEMMODEL_H
#define ITEMMODEL_H


#include <QObject>
#include <QStringList>
#include <functional>
#include "qlui_global.h"

class QLUISHARED_EXPORT ItemModel: public QObject
{
    Q_OBJECT
public:
    ItemModel(){}
    virtual ~ItemModel(){}

    virtual quint32 count() const = 0;
    virtual bool setData(int row, const QString& value){ return false; }
    virtual QString data(int row) const = 0;
    virtual void sort(Qt::SortOrder = Qt::AscendingOrder){}

};

class QLUISHARED_EXPORT SimpleItemModel : public ItemModel
{
public:
    typedef std::function<quint32()> CountFun;
    typedef std::function<QString(int)> DataFun;

    SimpleItemModel(CountFun count, DataFun data);

    virtual ~SimpleItemModel(){}

    virtual quint32 count() const override;
    virtual QString data(int row) const override;

private:
    CountFun count_fun_;
    DataFun data_fun_;
};
#endif // ITEMMODEL_H
